#include "qnewprojectdialog.h"
#include "ui_qnewprojectdialog.h"

#include <QMessageBox>
#include <QDir>

#include <QFileDialog>

QNewProjectDialog::QNewProjectDialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::QNewProjectDialog),
    m_ret(0)
{
    ui->setupUi(this);
    ui->pro_name->setText("");
    ui->pro_path->setText(QDir::currentPath());
}

QNewProjectDialog::~QNewProjectDialog()
{
    delete ui;
}

void QNewProjectDialog::on_ok_btn_clicked()
{
    if(ui->pro_name->text()=="")
    {
        QMessageBox::warning(this,tr("Warning"),tr("Project name can not been empty!"));
        return;
    }
    m_ret=1;
    close();
}

int QNewProjectDialog::getRet()
{
    return m_ret;
}

QString QNewProjectDialog::getProName()
{
    return ui->pro_name->text();
}

QString QNewProjectDialog::getProPath()
{
    return ui->pro_path->text();
}

void QNewProjectDialog::on_cancel_btn_clicked()
{
    close();
}

void QNewProjectDialog::on_path_clicked()
{
    QString path=QFileDialog::getExistingDirectory(this,tr("New Project"),ui->pro_path->text());
    if(path!="")
    {
        ui->pro_path->setText(path);
    }
}
